package scan

import (
	"net"
	"time"
)

// CheckTCPPort 扫描端口
func CheckTCPPort(address string, timeout time.Duration) (*ScanPortResult, error) {
	start := time.Now()
	conn, err := net.DialTimeout("tcp", address, timeout)
	if err != nil {
		// fmt.Println(err)
		return NewScanPortResult(false, time.Since(start)), err
	}
	conn.Close()
	return NewScanPortResult(true, time.Since(start)), nil
}
